<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.8.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"github.com","root":"/","scheme":"Pisces","version":"7.7.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="仰面朝天，知此身渺渺，沧海一粟">
<meta property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="https://github.com/LBraveHeart/page/4/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="仰面朝天，知此身渺渺，沧海一粟">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo">
<meta name="twitter:description" content="仰面朝天，知此身渺渺，沧海一粟">

<link rel="canonical" href="https://github.com/LBraveHeart/page/4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false
  };
</script>

  <title>Hexo</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Hexo</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="搜索..." spellcheck="false" type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/26/ea去除重复代码检测/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/26/ea去除重复代码检测/" class="post-title-link" itemprop="url">idea去除重复代码检测</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2019-07-26 17:36:00 / 修改时间：17:42:23" itemprop="dateCreated datePublished" datetime="2019-07-26T17:36:00+08:00">2019-07-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/idea/" itemprop="url" rel="index"><span itemprop="name">idea</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>12</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="如图："><a href="#如图：" class="headerlink" title="如图："></a>如图：</h2><p><img src="\images\pasted-6.png" alt></p>
<p>将红框部分去选勾选</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/26/xcel导出poi处理及table转为excel/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/26/xcel导出poi处理及table转为excel/" class="post-title-link" itemprop="url">excel导出poi处理及table转为excel</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2019-07-26 16:49:00 / 修改时间：17:28:14" itemprop="dateCreated datePublished" datetime="2019-07-26T16:49:00+08:00">2019-07-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/excel/" itemprop="url" rel="index"><span itemprop="name">excel</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="poi导出"><a href="#poi导出" class="headerlink" title="poi导出"></a>poi导出</h2><p>使用poi导出大量数据时，可以使用 <strong>SXSSFWorkbook</strong></p>
<h3 id="使用方法："><a href="#使用方法：" class="headerlink" title="使用方法："></a>使用方法：</h3><ol>
<li>导入poi包及poi-ooxml包</li>
</ol>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;poi&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;3.17&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;3.17&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>具体代码</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.liuyy.excel;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.apache.poi.ss.usermodel.Font;</span><br><span class="line"><span class="keyword">import</span> org.apache.poi.xssf.streaming.SXSSFCell;</span><br><span class="line"><span class="keyword">import</span> org.apache.poi.xssf.streaming.SXSSFRow;</span><br><span class="line"><span class="keyword">import</span> org.apache.poi.xssf.streaming.SXSSFSheet;</span><br><span class="line"><span class="keyword">import</span> org.apache.poi.xssf.streaming.SXSSFWorkbook;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.io.FileOutputStream;</span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> liuyy</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@className</span> PoiExcelDemo</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span> TODO</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@date</span> 2019/7/26 16:55</span></span><br><span class="line"><span class="comment"> **/</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PoiExcelDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        exportExcel(<span class="string">"数据导出.xls"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">exportExcel</span><span class="params">(String fileName)</span></span>&#123;</span><br><span class="line">        SXSSFWorkbook workbook = <span class="keyword">new</span> SXSSFWorkbook();</span><br><span class="line">        <span class="comment">//输出Excel文件</span></span><br><span class="line">        FileOutputStream output = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">//添加Worksheet（不添加sheet时生成的xls文件打开时会报错)</span></span><br><span class="line">            String sheetName = <span class="string">"数据导出"</span>;</span><br><span class="line">            SXSSFSheet sheet = workbook.createSheet(sheetName);</span><br><span class="line">            <span class="comment">// 设置缺省列高</span></span><br><span class="line">            sheet.setDefaultRowHeightInPoints(<span class="number">20</span>);</span><br><span class="line">            <span class="comment">// 设置缺省列宽</span></span><br><span class="line">            sheet.setDefaultColumnWidth(<span class="number">20</span>);</span><br><span class="line">            <span class="comment">// 设置字体</span></span><br><span class="line">            Font fontStyle = workbook.createFont();</span><br><span class="line">            fontStyle.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">            fontStyle.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">20</span>);</span><br><span class="line">            <span class="comment">// 创建XSSFRow对象</span></span><br><span class="line">            <span class="comment">// 创建第一行-表头</span></span><br><span class="line">            SXSSFRow rowHead = sheet.createRow(<span class="number">0</span>);</span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">8</span>; i++) &#123;</span><br><span class="line">                <span class="comment">//创建XSSFCell对象</span></span><br><span class="line">                SXSSFCell cellHead = rowHead.createCell(i);</span><br><span class="line">                <span class="comment">//设置单元格的值</span></span><br><span class="line">                cellHead.setCellValue(i);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 创建具体数据</span></span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">100</span>; i++) &#123;</span><br><span class="line">                <span class="comment">// 第i+1行</span></span><br><span class="line">                SXSSFRow row = sheet.createRow(i + <span class="number">1</span>);</span><br><span class="line">                row.createCell(<span class="number">0</span>).setCellValue(<span class="string">"第1列"</span>);</span><br><span class="line">                row.createCell(<span class="number">1</span>).setCellValue(<span class="string">"第2列"</span>);</span><br><span class="line">                row.createCell(<span class="number">2</span>).setCellValue(<span class="string">"第3列"</span>);</span><br><span class="line">                row.createCell(<span class="number">3</span>).setCellValue(<span class="string">"第4列"</span>);</span><br><span class="line">                row.createCell(<span class="number">4</span>).setCellValue(<span class="string">"第5列"</span>);</span><br><span class="line">                row.createCell(<span class="number">5</span>).setCellValue(<span class="string">"第6列"</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            output = <span class="keyword">new</span> FileOutputStream(fileName);</span><br><span class="line">            workbook.write(output);</span><br><span class="line">            output.flush();</span><br><span class="line">            workbook.close();</span><br><span class="line">            output.close();</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                workbook.close();</span><br><span class="line">                output.close();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="3">
<li><p>结果如果所示：</p>
<img src="/2019/07/26/xcel导出poi处理及table转为excel/pasted-5.png" title="excel">
</li>
</ol>
<h2 id="table导出"><a href="#table导出" class="headerlink" title="table导出"></a>table导出</h2><p>代码如下：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//获取表格</span></span><br><span class="line"><span class="keyword">var</span> exportFileContent = <span class="built_in">document</span>.getElementById(<span class="string">"showTable"</span>).outerHTML;</span><br><span class="line"><span class="comment">//设置格式为Excel，表格内容通过btoa转化为base64，此方法只在文件较小时使用(小于1M)</span></span><br><span class="line"><span class="comment">//exportFileContent = window.btoa(unescape(encodeURIComponent(exportFileContent)));</span></span><br><span class="line"><span class="comment">//var link = "data:"+MIMEType+";base64," + exportFileContent;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//使用Blob</span></span><br><span class="line"><span class="keyword">var</span> blob = <span class="keyword">new</span> Blob([exportFileContent], &#123;<span class="attr">type</span>: <span class="string">"text/plain;charset=utf-8"</span>&#125;);</span><br><span class="line"><span class="comment">//解决中文乱码问题</span></span><br><span class="line">blob =  <span class="keyword">new</span> Blob([<span class="built_in">String</span>.fromCharCode(<span class="number">0xFEFF</span>), blob], &#123;<span class="attr">type</span>: blob.type&#125;);</span><br><span class="line"><span class="comment">//设置链接</span></span><br><span class="line"><span class="keyword">var</span> link = <span class="built_in">window</span>.URL.createObjectURL(blob);</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> a = <span class="built_in">document</span>.createElement(<span class="string">"a"</span>);    <span class="comment">//创建a标签</span></span><br><span class="line">a.download = filenName+<span class="string">".xls"</span>;                <span class="comment">//设置被下载的超链接目标（文件名）</span></span><br><span class="line">a.href = link;                            <span class="comment">//设置a标签的链接</span></span><br><span class="line"><span class="built_in">document</span>.body.appendChild(a);            <span class="comment">//a标签添加到页面</span></span><br><span class="line">a.click();                                <span class="comment">//设置a标签触发单击事件</span></span><br><span class="line"><span class="built_in">document</span>.body.removeChild(a);            <span class="comment">//移除a标签</span></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/18/nteger-MAX-VALUE-面试题/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/18/nteger-MAX-VALUE-面试题/" class="post-title-link" itemprop="url">Integer.MAX_VALUE 面试题</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-07-18 16:02:00" itemprop="dateCreated datePublished" datetime="2019-07-18T16:02:00+08:00">2019-07-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-03-21 15:22:39" itemprop="dateModified" datetime="2020-03-21T15:22:39+08:00">2020-03-21</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>467</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="如下代码："><a href="#如下代码：" class="headerlink" title="如下代码："></a>如下代码：</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">final</span> <span class="keyword">int</span> start = Integer.MAX_VALUE-<span class="number">100</span>;</span><br><span class="line"><span class="keyword">final</span> <span class="keyword">int</span> end = Integer.MAX_VALUE;</span><br><span class="line"><span class="keyword">int</span> count = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">int</span> i = start; i &lt;= end;i++) &#123;</span><br><span class="line">	count++;</span><br><span class="line">&#125;</span><br><span class="line">System.out.println(count);</span><br></pre></td></tr></table></figure>
<p><img src="../images/pasted-4.png" alt="idea调试"></p>
<h2 id="输出结果为？"><a href="#输出结果为？" class="headerlink" title="输出结果为？"></a>输出结果为？</h2><p><strong>没有输出结果</strong></p>
<h2 id="分析"><a href="#分析" class="headerlink" title="分析"></a>分析</h2><p><code>Integer.MAX_VALUE</code>用二进制表示1111 1111 1111 1111 1111 1111 1111 111</p>
<p>所以当i++一直到=end时，即<code>i = Integer.MAX_VALUE</code>时,此时计算的结果为100，但是当接着往下面执行时，i++即 <code>i = Integer.MAX_VALUE+1</code>，i此时二进制1111 1111 1111 1111 1111 1111 1111 111 + 1 的结果为-1000 0000 0000 0000 0000 0000 0000 0000，即i = -2147483648，符合 <code>i &lt; end</code>条件，所以循环接着往下执行，一直到=end，+1后又变为负数，周而复始，所以不会有结果输出。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/18/ort-int-出人意料代码/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/18/ort-int-出人意料代码/" class="post-title-link" itemprop="url">short/int 易错面试题</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-07-18 11:46:00" itemprop="dateCreated datePublished" datetime="2019-07-18T11:46:00+08:00">2019-07-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-07-26 17:31:16" itemprop="dateModified" datetime="2019-07-26T17:31:16+08:00">2019-07-26</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>242</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">HashSet&lt;Short&gt; set = <span class="keyword">new</span> HashSet&lt;&gt;();</span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">short</span> i = <span class="number">0</span>; i &lt; <span class="number">100</span>; i++) &#123;</span><br><span class="line">    <span class="comment">// set.add set添加的类型为short</span></span><br><span class="line">    set.add(i);</span><br><span class="line">    <span class="comment">// 通过计算得知 int i1 = i - 1,i-1返回的是一个int类型的值，所以remove时找不到需要remove的值</span></span><br><span class="line">    set.remove(i-<span class="number">1</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 从而size是100</span></span><br><span class="line">System.out.println(set.size());</span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/17/程通讯协议-tcp-ip及nio的学习笔记/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/17/程通讯协议-tcp-ip及nio的学习笔记/" class="post-title-link" itemprop="url">远程通讯协议-tcp/ip及nio的学习笔记</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-07-17 17:39:00" itemprop="dateCreated datePublished" datetime="2019-07-17T17:39:00+08:00">2019-07-17</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-03-20 17:16:33" itemprop="dateModified" datetime="2020-03-20T17:16:33+08:00">2020-03-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/通讯协议/" itemprop="url" rel="index"><span itemprop="name">通讯协议</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="tcp-7层"><a href="#tcp-7层" class="headerlink" title="tcp 7层"></a>tcp 7层</h2><ul>
<li>应用层</li>
<li>表示层</li>
<li>会话层</li>
<li>传输层</li>
<li>网络层</li>
<li>数据链路层</li>
<li>物理层</li>
</ul>
<p>4层网络模型：</p>
<p>其中应用层、表示层、会话层表示应用层，数据链路层、物理层表示网络接口层</p>
<h2 id="ARP协议"><a href="#ARP协议" class="headerlink" title="ARP协议"></a>ARP协议</h2><p>复杂的程序都需要分层，软件开发设计必须要做的</p>
<h2 id="tcp负载均衡"><a href="#tcp负载均衡" class="headerlink" title="tcp负载均衡"></a>tcp负载均衡</h2><p>二层负载 -&gt; mac地址，vip(虚拟ip) 多个机器IP相同但是mac地址不同</p>
<p>三层负载 -&gt;ip 对外提供虚拟ip，集群中不同机器采用不用的ip，IP请求转发</p>
<p>四层负载 -&gt; 传输层负载，包含ip和端口，修改目标ip和端口地址</p>
<p>七层负载 -&gt; 应用层负载，请求的url，http请求的报文，如<a href="http://a/a.html,主机名。" target="_blank" rel="noopener">http://a/a.html,主机名。</a></p>
<h2 id="tcp和udp区别"><a href="#tcp和udp区别" class="headerlink" title="tcp和udp区别"></a>tcp和udp区别</h2><p>TCP/IP：可靠</p>
<ol>
<li>建立连接机制</li>
<li>三次握手建立连接<ol>
<li>client发送请求连接的数据包</li>
<li>server返回可以进行连接的数据包</li>
<li>client发送确认请求连接的数据包</li>
<li>client/server可以进行数据传输了</li>
</ol>
</li>
<li>SYNC攻击 -&gt; 客户端伪造大量ip和mac地址发送消息给服务器，占用服务器大量资源</li>
<li>连接的关闭，四次挥手协议<ol>
<li>client发送请求关闭连接的数据包</li>
<li>server返回确认收到请求关闭的数据包-此时server可能还处于数据操作的状况</li>
<li>server数据已经处理完毕，并返回可以关闭的数据包</li>
<li>client返回最终请求关闭数据包-此时server接收到数据包以后将处于关闭状态,而client可能还处于数据为未接受完的状态，等待2个固定的时间点后进入关闭状态</li>
</ol>
</li>
<li>TCP是一种全双工的协议</li>
<li>长连接，正常连接是超时关闭，但是长连接可以发送心跳包维持连接</li>
</ol>
<p>UDP/IP：不可靠</p>
<h2 id="在应用中如何去构建一个传输的实例"><a href="#在应用中如何去构建一个传输的实例" class="headerlink" title="在应用中如何去构建一个传输的实例"></a>在应用中如何去构建一个传输的实例</h2><p>socket -&gt; 套接字</p>
<p>socket io</p>
<p>file io</p>
<h2 id="通讯过程中的阻塞"><a href="#通讯过程中的阻塞" class="headerlink" title="通讯过程中的阻塞"></a>通讯过程中的阻塞</h2><p>accept阻塞(连接阻塞)</p>
<p>流操作的阻塞(read/write)</p>
<h2 id="滑动窗口的协议"><a href="#滑动窗口的协议" class="headerlink" title="滑动窗口的协议"></a>滑动窗口的协议</h2><h2 id="流量控制"><a href="#流量控制" class="headerlink" title="流量控制"></a>流量控制</h2><h2 id="BIO模型"><a href="#BIO模型" class="headerlink" title="BIO模型"></a>BIO模型</h2><blockquote>
<p>​    blocker  io 阻塞</p>
</blockquote>
<p>优化方案：</p>
<p>可以解决socket io阻塞，但是还是存在file io阻塞问题</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">ServerSocket server = <span class="keyword">new</span> ServerSocket(<span class="number">8080</span>);</span><br><span class="line"><span class="keyword">while</span>(<span class="keyword">true</span>) &#123;</span><br><span class="line">    Socket socket = server.accpet();</span><br><span class="line">    <span class="keyword">new</span> Thread(<span class="keyword">new</span> SocketThread(socket)).start;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SocketThread</span> <span class="keyword">implements</span> <span class="title">Runnable</span></span>&#123;</span><br><span class="line">    Socket socket;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">SocketThread</span><span class="params">(Socket socket)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.socket = socket;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 对socket进行操作</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="NIO"><a href="#NIO" class="headerlink" title="NIO"></a>NIO</h2><p>非阻塞</p>
<blockquote>
<p>​    new io / non blocker io</p>
</blockquote>
<p>多路复用机制</p>
<p>linux fd：linux系统中一切皆可看成是文件，文件描述符是内核为了高效管理已被打开的文件所创建的索引</p>
<p>serverSocket 向请求内核</p>
<p>先监听socket/fd，再如果发现socket/fd已就绪，就发送数据已经准备好的通知(即可以像该文件进行读写)，然后serverSocket再来发送read/write请求</p>
<p>linux提供的io复用机制</p>
<p>select/poll：轮询查询socket/fd是否已经就绪</p>
<p>epoll：事件机制，理解为注册监听机制，如果发现socket/fd就绪直接返回就绪通知，可以进行读写</p>
<h3 id="服务端的机器怎么去标记一个个的连接"><a href="#服务端的机器怎么去标记一个个的连接" class="headerlink" title="服务端的机器怎么去标记一个个的连接"></a>服务端的机器怎么去标记一个个的连接</h3><p>四元组：source_ip/source_port/target_ip/target_port </p>
<p>因为目标机器的ip和端口固定，所以最大连接数取决于客户端的数量</p>
<p>source_ip : 2^32</p>
<p>source_port:2^16 因为0不能作为端口，所以是65535个</p>
<ol>
<li>内存大小</li>
<li>文件句柄的限制</li>
<li>ulimit -n 默认是1024</li>
<li>带宽的资源</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/11/java8-lambda语法/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/11/java8-lambda语法/" class="post-title-link" itemprop="url">jdk8 部分新特性</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-07-11 12:01:00" itemprop="dateCreated datePublished" datetime="2019-07-11T12:01:00+08:00">2019-07-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-07-18 10:08:31" itemprop="dateModified" datetime="2019-07-18T10:08:31+08:00">2019-07-18</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="jdk1-8-时间的创建及工具类"><a href="#jdk1-8-时间的创建及工具类" class="headerlink" title="jdk1.8 时间的创建及工具类"></a>jdk1.8 时间的创建及工具类</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Clock</span></span><br><span class="line">Clock clock = Clock.systemDefaultZone();</span><br><span class="line">System.out.println(clock.millis());</span><br><span class="line">Instant instant = clock.instant();</span><br><span class="line">System.out.println(instant);</span><br><span class="line">Date from = Date.from(instant);</span><br><span class="line">System.out.println(from);</span><br><span class="line"><span class="comment">// 时区</span></span><br><span class="line"><span class="comment">// 获取所有时区</span></span><br><span class="line">Set&lt;String&gt; availableZoneIds = ZoneId.getAvailableZoneIds();</span><br><span class="line">System.out.println(availableZoneIds);</span><br><span class="line"><span class="comment">// 获取指定时区的ZoneId</span></span><br><span class="line">ZoneId of = ZoneId.of(<span class="string">"Asia/Aden"</span>);</span><br><span class="line">System.out.println(of.getRules());</span><br><span class="line"></span><br><span class="line"><span class="comment">// localtime 获取指定时区的时间</span></span><br><span class="line">LocalTime now = LocalTime.now(of);</span><br><span class="line">System.out.println(<span class="string">"当前时间是："</span>+now);</span><br><span class="line"></span><br><span class="line"><span class="comment">// localData 本地日期</span></span><br><span class="line">LocalDate today = LocalDate.now();</span><br><span class="line">System.out.println(<span class="string">"今天的日期是："</span>+today);</span><br><span class="line">LocalDate tomorrow = today.plus(<span class="number">1</span>, ChronoUnit.DAYS);</span><br><span class="line">System.out.println(<span class="string">"明天的日期是："</span>+tomorrow);</span><br><span class="line">LocalDate yesterday = today.plus(-<span class="number">1</span>, ChronoUnit.DAYS);</span><br><span class="line">System.out.println(<span class="string">"昨天的日期是："</span>+yesterday);</span><br><span class="line"><span class="comment">// 创建指定日期</span></span><br><span class="line">LocalDate of1 = LocalDate.of(<span class="number">2019</span>, Month.JUNE, <span class="number">11</span>);</span><br><span class="line">System.out.println(of1);</span><br><span class="line">DayOfWeek dayOfWeek = of1.getDayOfWeek();</span><br><span class="line">System.out.println(<span class="string">"今天是周几："</span>+dayOfWeek);</span><br><span class="line"><span class="comment">// DateTimeFormatter格式化时间</span></span><br><span class="line">DateTimeFormatter formatter = DateTimeFormatter.ofPattern(<span class="string">"yyyy年MM月dd日"</span>);</span><br><span class="line">String format = formatter.format(today);</span><br><span class="line">System.out.println(format);</span><br></pre></td></tr></table></figure>
<h2 id="Stream"><a href="#Stream" class="headerlink" title="Stream"></a>Stream</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line">List&lt;String&gt; stringList = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">stringList.add(<span class="string">"ddd2"</span>);</span><br><span class="line">stringList.add(<span class="string">"aaa2"</span>);</span><br><span class="line">stringList.add(<span class="string">"bbb1"</span>);</span><br><span class="line">stringList.add(<span class="string">"aaa1"</span>);</span><br><span class="line">stringList.add(<span class="string">"bbb3"</span>);</span><br><span class="line">stringList.add(<span class="string">"ccc"</span>);</span><br><span class="line">stringList.add(<span class="string">"bbb2"</span>);</span><br><span class="line">stringList.add(<span class="string">"ddd1"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// stream 串行</span></span><br><span class="line"><span class="comment">// 过滤</span></span><br><span class="line">stringList</span><br><span class="line">     .stream()</span><br><span class="line">    .filter(s -&gt; s.startsWith(<span class="string">"a"</span>))</span><br><span class="line">    .forEach(System.out::println);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 排序</span></span><br><span class="line"><span class="comment">// 排序只是创建了一个排序好的stream，原数据并没有改变</span></span><br><span class="line">stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .sorted()</span><br><span class="line">    .filter(s -&gt; s.startsWith(<span class="string">"a"</span>))</span><br><span class="line">    .forEach(System.out::println);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// map映射,map操作</span></span><br><span class="line">stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .map(String::toUpperCase)</span><br><span class="line">    .sorted((o1, o2) -&gt; o2.compareTo(o1))</span><br><span class="line">    .forEach(System.out::println);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 匹配，任一一个匹配就可以返回</span></span><br><span class="line"><span class="keyword">boolean</span> anyMatch = stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .anyMatch(s -&gt; s.startsWith(<span class="string">"a"</span>));</span><br><span class="line">System.out.println(anyMatch);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 匹配，所有匹配，所有匹配到才会返回true</span></span><br><span class="line"><span class="keyword">boolean</span> allMatch = stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .allMatch(s -&gt; s.startsWith(<span class="string">"a"</span>));</span><br><span class="line">System.out.println(allMatch);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 匹配,没有匹配到的返回true，如果有匹配到的则返回false</span></span><br><span class="line"><span class="keyword">boolean</span> noneMatch = stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .noneMatch(s -&gt; s.startsWith(<span class="string">"a"</span>));</span><br><span class="line">System.out.println(noneMatch);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 计数</span></span><br><span class="line"><span class="keyword">long</span> count = stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .filter(s -&gt; s.startsWith(<span class="string">"a"</span>))</span><br><span class="line">    .count();</span><br><span class="line">System.out.println(count);</span><br><span class="line">System.out.println(<span class="string">"-----------------------"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 规约,将集合整合为一个元素</span></span><br><span class="line">Optional&lt;String&gt; reduce = stringList</span><br><span class="line">    .stream()</span><br><span class="line">    .sorted()</span><br><span class="line">    .reduce((s, s2) -&gt; s + <span class="string">"#"</span> + s2);</span><br><span class="line">reduce.ifPresent(System.out::println);</span><br></pre></td></tr></table></figure>
<h2 id="lambda语法创建接口"><a href="#lambda语法创建接口" class="headerlink" title="lambda语法创建接口"></a>lambda语法创建接口</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">InteTest</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">initData</span><span class="params">(String string)</span></span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        InteTest inteTest = string -&gt; &#123;</span><br><span class="line">            System.out.println(string);</span><br><span class="line">        &#125;;</span><br><span class="line">        inteTest.initData(<span class="string">"123"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/07/02/务及SpringCloud的一些面试问题/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/07/02/务及SpringCloud的一些面试问题/" class="post-title-link" itemprop="url">微服务及SpringCloud的一些面试问题</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-07-02 15:47:00" itemprop="dateCreated datePublished" datetime="2019-07-02T15:47:00+08:00">2019-07-02</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-07-03 14:17:59" itemprop="dateModified" datetime="2019-07-03T14:17:59+08:00">2019-07-03</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>855</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="soa和微服务的区别"><a href="#soa和微服务的区别" class="headerlink" title="soa和微服务的区别"></a>soa和微服务的区别</h2><p>   soa:面向服务的框架，着重于将应用系统根据不同的业务模块拆分不同的服务，并通过这些服务定义好的接口联系起来。它是一种粗粒度，松耦合的框架，主要解决的是服务重复性问题。</p>
<p>   微服务:微服务是soa架构下的最终产物，它相对soa来说对系统的拆分更加彻底，拆分粒度更细，拆分后的服务都可以单独的运行。微服务主要解决的是服务的高耦合问题，通过降低服务之间的耦合度来把服务分割的更彻底，每个服务都可以不依赖于其他服务而独立运行，当一个服务出问题时，对其他服务并不会造成影响。</p>
<p>   soa和微服务都是分布式的具体实现思想。</p>
<h2 id="你是怎么理解微服务的？"><a href="#你是怎么理解微服务的？" class="headerlink" title="你是怎么理解微服务的？"></a>你是怎么理解微服务的？</h2><p>   微服务顾名思义就是将系统拆分为一个个可以独立部署、水平扩展、独立运行的细微服务。</p>
<p>   使用微服务的思想通过对单体架构的系统进行细粒度的拆分，从而降低各个服务之间的耦合度，单个服务中如果出现问题而不会对其他服务产生影响。并且通过对系统的拆分，会极大的解决原单体架构系统中的有些业务运行速度过慢而对其他业务造成的影响。</p>
<h2 id="什么是SpringCloud"><a href="#什么是SpringCloud" class="headerlink" title="什么是SpringCloud"></a>什么是SpringCloud</h2><p>   SpringCloud可以通俗的理解为整合各个分布式基础设施的工具箱，它是一系列框架的有序集合，注重于服务治理。</p>
<h2 id="微服务架构的优点和缺点有哪些？"><a href="#微服务架构的优点和缺点有哪些？" class="headerlink" title="微服务架构的优点和缺点有哪些？"></a>微服务架构的优点和缺点有哪些？</h2><p>   微服务的主要作用是大型业务系统进行细粒度的拆分，从而降低项目开发时某一模块的开发对其他模块业务开发的影响，可以将项目中的各个模块更快地上线落地，相对传统的单体架构中一块出问题其他都会被影响，微服务带来的是更加敏捷的更新维护，当其中一个服务出问题时，其他服务不会受到影响。但是当系统拆分的太细致，造成的运维成本也相对的更大，梳理各服务的功能调用逻辑更麻烦，本来只需要对一个系统的维护现在变相的变成对多个系统的维护，这样的成本会大大的增大。</p>
<h2 id="SpringCloud解决了什么问题？"><a href="#SpringCloud解决了什么问题？" class="headerlink" title="SpringCloud解决了什么问题？"></a>SpringCloud解决了什么问题？</h2><p>   SpringCloud利用SpringBoot的开发便利性简化了分布式系统基础设施的开发，如服务发现注册、配置中心、消息总线、熔断器、数据监控、负载均衡等，都可以利用SpringBoot的开发风格做到一键部署和启动。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/06/26/latile/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/06/26/latile/" class="post-title-link" itemprop="url">java并发编程-volatile关键字</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2019-06-26 16:16:00 / 修改时间：17:36:14" itemprop="dateCreated datePublished" datetime="2019-06-26T16:16:00+08:00">2019-06-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>981</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="并发编程"><a href="#并发编程" class="headerlink" title="并发编程"></a>并发编程</h1><h2 id="MESI协议"><a href="#MESI协议" class="headerlink" title="MESI协议"></a>MESI协议</h2><p>基于失效的缓存一致性协议</p>
<p>有四个状态:</p>
<ul>
<li>Exclusive(E)：独享，其他缓存都没有有效的副本</li>
<li>Shared(S)：共享，其他缓存都有有效的副本</li>
<li>Invalid(I)：失效</li>
<li>Modified(M)：修改</li>
</ul>
<h2 id="原子性、有序性、可见性"><a href="#原子性、有序性、可见性" class="headerlink" title="原子性、有序性、可见性"></a>原子性、有序性、可见性</h2><h3 id="原子性"><a href="#原子性" class="headerlink" title="原子性"></a>原子性</h3><p>在java中，对基本数据类型的变量读取和赋值操作是原子性操作，这些操作是不可中断的，也就是要么读，要么不读，或者要么写要么不写。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">x = <span class="number">10</span>; <span class="comment">// 操作1</span></span><br><span class="line">y = x;	<span class="comment">// 操作2</span></span><br><span class="line">x++;	<span class="comment">// 操作3</span></span><br><span class="line">x = x + <span class="number">1</span>;<span class="comment">//操作4</span></span><br></pre></td></tr></table></figure>
<p>以上的操作中只有操作1属于原子性操作。</p>
<h3 id="有序性"><a href="#有序性" class="headerlink" title="有序性"></a>有序性</h3><p>有以下这样的代码：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> x = <span class="number">10</span>;</span><br><span class="line"><span class="comment">//volatile int x = 10; 如果x有volatile关键字修饰时,就可以保证有序性</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">cpu0</span><span class="params">()</span></span>&#123;</span><br><span class="line">	</span><br><span class="line">    x = <span class="number">100</span>;<span class="comment">// 此时x的状态变幻情况为：S(共享) -&gt; M(修改),此时通过cpu0会通知其他cpu的x的值为I(失效)，再取出最新值，会消耗一段时间才会将x的值修改完成</span></span><br><span class="line">    flag = <span class="keyword">true</span>;<span class="comment">// 当flag此时是E状态时，变化状态:E(独享) -&gt; M(修改)，此时flag的值会直接修改，并发送给其他cpu状态置为S(共享)</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">cpu1</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">while</span>(flag) &#123;</span><br><span class="line">   	System.out.println(x == <span class="number">100</span>);</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>当有volatile关键字修饰时，会看到在程序运行时的汇编指令中会发现有locak指令，相当于一个内存屏障，会强制把缓存的操作写入主存。</p>
<p>当不能保证有序性时，打印输出的结果可能为false。所以在程序运行必须保证有序性。</p>
<h3 id="可见性"><a href="#可见性" class="headerlink" title="可见性"></a>可见性</h3><p>在Java中，提供了volatile关键保证可见性。<br>当一个共享变量被volatile修饰时，它会保证修改的值会立即被更新到主存，当有其他线程需要读取时，它会去内存中读取新值。<br>此外，通过synchronized和Lock也能够保证可见性，synchronized和Lock能保证同一时刻只有一个线程获取锁然后执行同步代码，并且在释放锁之前会将对变量的修改刷新到主存当中。因此可以保证可见性。</p>
<h3 id="volatile、synchronized"><a href="#volatile、synchronized" class="headerlink" title="volatile、synchronized"></a>volatile、synchronized</h3><p>volatile可以保证对变量操作的有序性、可见性，但是不能保证原子性</p>
<p>synchronized可以保证对变量的有序性、可见性、原子性</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/06/11/nux的5中io模型/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/06/11/nux的5中io模型/" class="post-title-link" itemprop="url">linux的5种io模型</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-06-11 18:27:00" itemprop="dateCreated datePublished" datetime="2019-06-11T18:27:00+08:00">2019-06-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-06-12 09:26:41" itemprop="dateModified" datetime="2019-06-12T09:26:41+08:00">2019-06-12</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/linux/" itemprop="url" rel="index"><span itemprop="name">linux</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>40</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="linux的5种io模型"><a href="#linux的5种io模型" class="headerlink" title="linux的5种io模型"></a>linux的5种io模型</h2><h3 id="阻塞式io"><a href="#阻塞式io" class="headerlink" title="阻塞式io"></a>阻塞式io</h3><h3 id="非阻塞式io"><a href="#非阻塞式io" class="headerlink" title="非阻塞式io"></a>非阻塞式io</h3><h3 id="信号驱动式io"><a href="#信号驱动式io" class="headerlink" title="信号驱动式io"></a>信号驱动式io</h3><h3 id="io复用模式"><a href="#io复用模式" class="headerlink" title="io复用模式"></a>io复用模式</h3><h3 id="异步io"><a href="#异步io" class="headerlink" title="异步io"></a>异步io</h3>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://github.com/LBraveHeart/2019/06/05/RL与URI的区别/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="liu666">
      <meta itemprop="description" content="仰面朝天，知此身渺渺，沧海一粟">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2019/06/05/RL与URI的区别/" class="post-title-link" itemprop="url">URL与URI的区别</a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-06-05 16:20:36" itemprop="dateCreated datePublished" datetime="2019-06-05T16:20:36+08:00">2019-06-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-03-21 15:07:18" itemprop="dateModified" datetime="2020-03-21T15:07:18+08:00">2020-03-21</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>523</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="URL、URI的区别"><a href="#URL、URI的区别" class="headerlink" title="URL、URI的区别"></a>URL、URI的区别</h1><h2 id="定义"><a href="#定义" class="headerlink" title="定义"></a>定义</h2><h3 id="URL-统一资源定位符"><a href="#URL-统一资源定位符" class="headerlink" title="URL:统一资源定位符"></a>URL:统一资源定位符</h3><p>代表的是一个具体的资源位置，如<code>http://localhost:8081/spring/demo/query?name=1</code></p>
<h3 id="URI：统一资源标识符"><a href="#URI：统一资源标识符" class="headerlink" title="URI：统一资源标识符"></a>URI：统一资源标识符</h3><p>用于标识互联网资源名称的字符串，URI最常见的形式是URL，所有URL是URI的子集，URI属于URL更好层次的抽象，一种字符串文本标准。如<code>/spring/demo/query</code>，着重于表示资源的名称</p>
<h2 id="组成"><a href="#组成" class="headerlink" title="组成"></a>组成</h2><h3 id="URI"><a href="#URI" class="headerlink" title="URI"></a>URI</h3><p>Web上可用的每种资源如HTML文档、图像、视频片段、程序等都是一个来URI来定位的.</p>
<h3 id="URL"><a href="#URL" class="headerlink" title="URL"></a>URL</h3><p>URL可以用一种统一的格式来描述各种信息资源，包括文件、服务器的地址和目录</p>
<p>一个URL例如：<code>http://localhost:8081/spring/demo/query?name=1</code></p>
<p>组成部分为：schema://host[:port]/path/…/?[url-params]#[query-string]</p>
<p>包含以下组成部分：</p>
<ul>
<li>schema：指定应用层使用的协议，例如：http，https，ftp</li>
<li>host：http服务器的域名或ip</li>
<li>port：端口，可选项，80端口可以不填，如果使用了其他端口，则必须说明</li>
<li>path：请求的路径</li>
<li>query-string：请求参数</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

  </div>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">liu666</p>
  <div class="site-description" itemprop="description">仰面朝天，知此身渺渺，沧海一粟</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">63</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">55</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/LBraveHeart" title="GitHub → https://github.com/LBraveHeart"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:446109730@qq.com" title="E-Mail → mailto:446109730@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">liu666</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">58k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">53 分钟</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.8.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://pisces.theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.7.2
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>












  

  

</body>
</html>
